home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch01 / grdriver.h < prev    next >
Text File  |  1993-12-06  |  10KB  |  240 lines

  1. /**
  2.  ** This is file GRDRIVER.H
  3.  **
  4.  ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  5.  ** Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  6.  ** Copyright (C) 1993 Grzegorz Mazur, gbm@ii.pw.edu.pl
  7.  **
  8.  ** This file is distributed under the terms listed in the document
  9.  ** "copying.dj", available from DJ Delorie at the address above.
  10.  ** A copy of "copying.dj" should accompany this file; if not, a copy
  11.  ** should be available from where this file was obtained.  This file
  12.  ** may not be distributed without a verbatim copy of "copying.dj".
  13.  **
  14.  ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  15.  ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16.  **/
  17.  
  18. #ifndef _GRDRIVER_H_
  19. #define _GRDRIVER_H_
  20.  
  21. #if defined(__GNUC__) && !defined(near)
  22. # define near
  23. # define far
  24. # define huge
  25. #endif
  26.  
  27. /* ================================================================== */
  28. /*              DRIVER HEADER STRUCTURES                  */
  29. /* ================================================================== */
  30.  
  31. typedef struct {
  32.     /*
  33.      * ---------------------- GRD ----------------------------
  34.      * slots present in all (.GRD, .GRN, .VDR) driver versions
  35.      */
  36.     unsigned short  modeset_routine;
  37.     unsigned short  paging_routine;
  38.     unsigned short  driver_flags;
  39.     unsigned short  def_tw;
  40.     unsigned short  def_th;
  41.     unsigned short  def_gw;
  42.     unsigned short  def_gh;
  43.     /*
  44.      * ---------------------- GRN ----------------------------
  45.      * The next fields are present only in the ".GRN" (introduced with GRX 1.01)
  46.      * format drivers. ".GRN" format drivers are indicated by the 'GR_NEW_DRIVER'
  47.      * bit (see below) set in the 'driver_flags' word. The text and graphics
  48.      * table entries are offsets to tables of GR_DRIVER_MODE_ENTRY structures.
  49.      */
  50.     unsigned short  def_numcolor;
  51.     unsigned short  driver_init_routine;
  52.     unsigned short  text_table;
  53.     unsigned short  graphics_table;
  54.     /*
  55.      * The following entry was defined for GRX 1.02, but page flipping was never
  56.      * implemented in this form. The new virtual screen feature of GRX 1.03
  57.      * makes this obsolete.
  58.      */
  59.     unsigned short  pageflip_routine;
  60.     /*
  61.      * ---------------------- VDR ----------------------------
  62.      * All subsequent fields are present only in the ".VDR" driver format
  63.      * introduced with GO32 1.11 and GRX 1.03. ".VDR" format drivers can be
  64.      * recognized by first checking for the ".GRN" format, then comparing
  65.      * the 'vdr_magic' string with ".VDR driver".
  66.      * The next fields are hard-coded in the driver binary:
  67.      */
  68.     unsigned char   vdr_magic[12];    /* indicates VDR format */
  69.     unsigned short  driver_name_offset; /* just for documentation */
  70.     unsigned short  set_screen_start;    /* page flip/scroll function */
  71.     /*
  72.      * field configured by GO32 from env. var. options when driver is loaded:
  73.      */
  74.     unsigned short  driver_options;    /* driver control bits: see defs below */
  75.     /*
  76.      * fields filled out by the driver initialization routine
  77.      */
  78.     unsigned short  memory_size;    /* total video adapter memory in 4KByte units */
  79.     /*
  80.      * fields read/written both by the driver and GO32 during every mode set
  81.      */
  82.     unsigned short  virt_x_res;        /* virtual X res; GO32: writes desired, drv: reports actual */
  83.     unsigned short  virt_y_res;        /* virtual Y res; GO32: writes desired, drv: reports actual */
  84.     void     far  (*VESA_paging_fnc)(); /* VESA paging fn; drv: reports real mode, GO32: cvt to prot */
  85.     /*
  86.      * driver uses these after every mode set to report mode dependent
  87.      * parameters to the extender and graphics libraries
  88.      */
  89.     unsigned short  line_offset;    /* scan line length */
  90.     unsigned short  wr_page_start;    /* start paragraph of the writable (or single R/W) page */
  91.     unsigned short  rd_page_start;    /* start paragraph of the readable page (FFFF => single) */
  92.     unsigned char   page_size_shift;    /* log2 of page size/4kB */
  93.     unsigned char   page_gran_shift;    /* log2 of VESA page size/granularity */
  94.     unsigned char   r_mask,r_offs;    /* pixel format info in VESA 1.2 style: */
  95.     unsigned char   g_mask,g_offs;    /*   used in TrueColor modes by the */
  96.     unsigned char   b_mask,b_offs;    /*   GRX (1.03+) graphics library   */
  97.     unsigned char   f_mask,f_offs;    /* VESA 1.2 says there may be fill bits */
  98.     /*
  99.      * these are here to support future GRX and GO32 developments
  100.      */
  101.     unsigned long   linear_addr;    /* starting at this extended memory address */
  102.     unsigned short  linear_size;    /* if > 0 then map this many 4 kByte pages */
  103.     unsigned short  paging_fnc32;    /* offset of 32 bit paging function */
  104. } GrDriverHeader;
  105.  
  106. typedef struct {
  107.     unsigned short  width;
  108.     unsigned short  height;
  109.     unsigned short  number_of_colors;
  110.     union {
  111. #if defined(__GNUC__) || defined(__TURBOC__)
  112.        struct {
  113.        unsigned short BIOS_mode:12;
  114.        unsigned short custom_setup_index:4;
  115.        } vdr;
  116. #else
  117. #      error Check how your compiler aligns bitfields before you use this code!
  118. #endif
  119.        struct {
  120.        unsigned char  BIOS_mode;
  121.        unsigned char  custom_setup_index;
  122.        } grn;
  123.     } mode;
  124. } GrModeEntry,GR_DRIVER_MODE_ENTRY;
  125.  
  126.  
  127. /* ================================================================== */
  128. /*       DRIVER FLAG (THIRD WORD IN DRIVER HEADER) BITS          */
  129. /* ================================================================== */
  130.  
  131. #define GRD_NEW_DRIVER  0x0008        /* NEW FORMAT DRIVER IF THIS IS SET */
  132.  
  133. #define GRD_PAGING_MASK 0x0007        /* mask for paging modes */
  134. #define GRD_NO_RW    0x0000        /* standard paging, no separate R/W */
  135. #define GRD_RW_64K    0x0001        /* two separate (formerly 64K only) R/W pages */
  136. /* !!! THE FOLLOWING THREE OPTIONS ARE NOT SUPPORTED AND/OR OBSOLETE !!! */
  137. #define GRD_RW_32K    0x0002        /* two separate 32Kb pages */
  138. #define GRD_MAP_128K    0x0003        /* 128Kb memory map -- some Tridents do it */
  139. #define GRD_MAP_EXTMEM  0x0004        /* Can be mapped extended, above 1M. */
  140. /* !!! */
  141.  
  142. #define GRD_TYPE_MASK    0xf000        /* adapter type mask */
  143. #define GRD_VGA        0x0000        /* vga */
  144. #define GRD_EGA        0x1000        /* ega */
  145. #define GRD_HERC    0x2000        /* hercules */
  146. #define GRD_8514A    0x3000        /* IBM 8514A or compatible */
  147. #define GRD_S3        0x4000        /* S3 graphics accelerator */
  148. /* ++ GRX 1.03 ".VDR" format */
  149. #define GRD_W9000    0x5000        /* Weitek 9000 accelerator */
  150.  
  151. #define GRD_PLANE_MASK  0x0f00        /* bitplane number mask */
  152. #define GRD_8_PLANES    0x0000        /* 8 planes = 256 colors */
  153. #define GRD_4_PLANES    0x0100        /* 4 planes = 16 colors */
  154. #define GRD_1_PLANE    0x0200        /* 1 plane = 2 colors */
  155. #define GRD_16_PLANES    0x0300        /* VGA with 32K colors (really only 15 planes) */
  156. #define GRD_8_X_PLANES  0x0400        /* VGA in mode X w/ 256 colors */
  157. /* ++ GRX 1.03 ".VDR" format */
  158. #define GRD_8_F_PLANES  0x0500        /* VGA 256c switchable betw. linear and modeX */
  159. #define GRD_16_R_PLANES 0x0600        /* The "real" 16 plane mode with 64K colors */
  160. #define GRD_24_PLANES    0x0700        /* 24 plane "TrueColor" mode */
  161.  
  162. #define GRD_MEM_MASK    0x00f0        /* memory size mask */
  163. #define GRD_M_NOTSPEC    0x0000        /* memory amount not specified */
  164. #define GRD_64K        0x0010        /* 64K display memory */
  165. #define GRD_128K    0x0020        /* 128K display memory */
  166. #define GRD_256K    0x0030        /* 256K display memory */
  167. #define GRD_512K    0x0040        /* 512K display memory */
  168. #define GRD_1024K    0x0050        /* 1MB display memory */
  169. #define GRD_192K    0x0060        /* 192K -- some 640x480 EGA-s */
  170. /* ++ GRX 1.03 ".VDR" format */
  171. #define GRD_1536K    0x0070        /* 1.5 MB */
  172. #define GRD_2048K    0x0080        /* 2.0 MB */
  173. #define GRD_3072K    0x0090        /* 3.0 MB */
  174. #define GRD_4096K    0x00a0        /* 4.0 MB */
  175.  
  176.  
  177. /* ================================================================== */
  178. /*     DRIVER CONTROL BITS (SET BY GO32 WHEN DRIVER IS LOADED)      */
  179. /* ================================================================== */
  180.  
  181. #define GRD_FAST_256_MODE    1    /* switch betw. lin. and planar 256 c. modes */
  182. #define GRD_PROTECTED_PAGING    2    /* use paging function in protected mode */
  183. #define GRD_15_PLANE_MODE    4    /* VESA reported 16 bpp mode is really only 15 */
  184. #define GRD_ENABLE_LINEAR_VRAM  8    /* ext. memory linear mapping (not sup yet) */
  185.  
  186.  
  187. /* ================================================================== */
  188. /*             COMPILER-DEPENDENT CONSTANTS              */
  189. /* ================================================================== */
  190.  
  191. #ifdef __GNUC__
  192. # define VGA_FRAME    0xd0000000    /* VGA video RAM */
  193. # define HERC_FRAME    0xe00b0000    /* Hercules frame addr */
  194. # define EGA_FRAME    0xe00a0000    /* EGA frame addr */
  195. # define RDONLY_OFF    0x00100000    /* VGA dual page: Read only */
  196. # define WRONLY_OFF    0x00200000    /* VGA dual page: Write only */
  197. # define BIG_VGA_FRAME  0xd1000000    /* 16MB VGA video RAM */
  198. # define BIG_RDONLY_OFF 0x01000000    /* 16MB VGA dual page: Read only */
  199. # define BIG_WRONLY_OFF 0x02000000    /* 16MB VGA dual page: Write only */
  200. #endif
  201.  
  202. #ifdef __TURBOC__
  203. # define VGA_FRAME    0xa0000000UL    /* VGA video RAM */
  204. # define EGA_FRAME    0xa0000000UL    /* EGA video RAM */
  205. # define HERC_FRAME    0xb0000000UL    /* Hercules frame addr */
  206. # define RDONLY_OFF    0        /* VGA dual page: Read only */
  207. # define WRONLY_OFF    0        /* VGA dual page: Write only */
  208. #endif
  209.  
  210.  
  211. /* ================================================================== */
  212. /*              DRIVER INTERFACE FUNCTIONS              */
  213. /* ================================================================== */
  214.  
  215. extern long _GrGetDriverModes(GrModeEntry far **t,GrModeEntry far **g);
  216. extern long _GrLowSetMode(int mode,int width,int height,int colors);
  217.  
  218. #ifdef __TURBOC__
  219. extern void _GrSetVideoPage(int page);
  220. extern void _GrSetAsmPage(void);    /* takes page(s) in AL, AH */
  221. #endif
  222.  
  223. #define GrGetDriverModes _GrGetDriverModes
  224.  
  225. /*
  226.  * Values returned by _GrGetDriverModes and _GrLowSetMode in the
  227.  * upper half of their returned long. (The lower half is the driver
  228.  * option word.) This was introduced in GO32 1.11, before that
  229.  * this word was either zero or sign extended. (Does not matter which
  230.  * since neither can match these return values.) These values can be
  231.  * used by the graphics libraries to determine what version of the
  232.  * extender they are talking to.
  233.  */
  234. #define GR_DRV_VER_GRD  0x19910000L
  235. #define GR_DRV_VER_GRN  0x19920000L
  236. #define GR_DRV_VER_VDR  0x19930000L
  237.  
  238. #endif /* whole file */
  239.  
  240.